﻿Imports SISSAT.BusinessLayer.DomainModels
Imports SISSAT.Administration.DomainModels
Imports SISSAT.BusinessLayer.Utilities

Namespace Views
    Public Class SISSATPageBase

        Public Shared Property User As SouthdaleUser
            Get
                If CType(HttpContext.Current.Session("SouthdaleUser"), SouthdaleUser) Is Nothing Then
                    HttpContext.Current.Response.Redirect("/SignOut.aspx")
                End If

                Return CType(HttpContext.Current.Session("SouthdaleUser"), SouthdaleUser)
            End Get
            Set(value As SouthdaleUser)
                HttpContext.Current.Session.Add("SouthdaleUser", value)
            End Set
        End Property

        Public Shared ReadOnly Property Semester As Semesters
            Get
                Return SemesterHelper.GetCurrentSemester()
            End Get
        End Property

        Public Shared ReadOnly Property SchoolYear As Integer
            Get
                Return SemesterHelper.GetCurrentSchoolYear()
            End Get
        End Property

        Public Shared Function AppropriatePageModeForUser() As PageModes
            Dim employeeTypeId As Integer = SISSATPageBase.User.Employee.EmployeeType.EmployeeTypeId
            Dim pageMode As PageModes = _
                CType(IIf(employeeTypeId < 3, PageModes.EditMode, PageModes.ViewMode), PageModes)
            Return pageMode
        End Function

    End Class
End Namespace

